package com.sky.controller.mobile;


import com.sky.context.BaseContext;
import com.sky.dto.UserLoginDTO;
import com.sky.entity.User;
import com.sky.properties.JwtProperties;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "C端用户相关接口")
@RestController
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result userLogin(@RequestBody UserLoginDTO userLoginDTO){
        UserLoginVO userLoginVO = userService.wxlogin(userLoginDTO);
        // 获取jwt令牌
        return Result.success(userLoginVO);
    }

    @ApiOperation("用户退出")
    @PostMapping("/logout")
    public Result logout(){
        BaseContext.removeCurrentId();
        return Result.success();
    }
}
